{extend name="common/base"/}
{block name="style"}
<link rel="stylesheet" href="{__STATIC__}/home/style/index.css?v={$version}">
{/block}
{block name="title"}
<title>{:get_seo_str('home','home_title')}</title>	
{/block}
{block name="keywords"}
<meta name="keywords" content="{:get_seo_str('home','home_keywords')}"/>
<meta name="description" content="{:get_seo_str('home','home_description')}"/>
{/block}
<!-- 主体 -->
{block name="body"}
	{include file="common/header" nav='info' /}	
	<section class="hero-area">
		<div class="hero-circle">
		</div>
		<div class="container">
			<div class="row slider_list owl-carousel">
				{php}$slide = model('slide_info')->where(['slide_id'=>1, 'status' => 1])->order('sort desc')->select()->toArray();{/php}
				{notempty name="slide"}
					{volist name="$slide" id="v"}
						{eq name="$v.type" value="2"}
							{$v.desc|raw}
						{/eq}
						{eq name="$v.type" value="1"}
							<a href="{$v.src}" target="_blank"><img src="{:get_file($v.img)}" alt="{$v.title}"></a>
						{/eq}
					{/volist}				
				{/notempty}
			</div>
		</div>
	</section>

	<div class="container">
		<section class="home-tap-link">
			<div class="home-tap-link__left" >
				<a href="{:url('quanben')}" title="全本" class="home-tap-link__left-item">
					<div><img src="{__STATIC__}/home/image/4cda7fc.png" class="animation-img"></div><span>全本</span>
				</a>
				<a href="{:url('rank')}" title="排行榜" class="home-tap-link__left-item">
					<div><img src="{__STATIC__}/home/image/624b3b7.png" class="animation-img"></div><span>排行</span>
				</a>
				<a href="{:url('shuku')}" title="书库" class="home-tap-link__left-item" >
					<div><img src="{__STATIC__}/home/image/f99bbe4.png" class="animation-img"></div><span>书库</span>
				</a>
			</div>
			<div class="home-tap-link__center">
				{volist name=":model('category')->where(['status' => 1,'pid' => 0])->order('ordernum asc')->select()" id="vo"}
					<a href="{:furl('book_cates', ['id'=>$vo.key ? $vo.key : $vo.id], true, 'home')}" title="{$vo.name}" class="home-tap-link__center-item">
						{$vo.name}
						{php}$sublist = model('category')->where(['status' => 1, 'pid' => $vo['id']])->order('ordernum asc')->select()->toArray();{/php}
						{notempty name="sublist"}
							<ul>
								{volist name="$sublist" id="v"}
									<li onclick="window.location.href = '{:furl('book_cates', ['id'=>$v.key ? $v.key : $v.id], true, 'home')}';">{$v.name}</li>
								{/volist}
							</ul>
						{/notempty}
					</a>
                {/volist}
			</div>
			<script>
			$('.home-tap-link__center-item ul li').on('click', function () {
				event.stopPropagation();
    			event.preventDefault();
			})
			</script>
			<div class="home-tap-link__right">
				<a href="{:url('bookshelf')}" class="home-tap-link__right-item">我的书架</a>
				<a href="{:url('readlog')}" class="home-tap-link__right-item">阅读记录</a>
				<a href="{:url('my')}"  class="home-tap-link__right-item">个人中心</a>
				<a href="{:url('quanben')}" class="home-tap-link__right-item">完本专区</a>
				<a href="javascript:;" class="home-tap-link__right-item">加入我们</a>
				<a href="javascript:;" class="home-tap-link__right-item">帮助中心</a>
			</div>
		</section>
	</div>

	{php}$notice = model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_notice'], 'type' => 6])->order('level desc')->limit(6)->select()->toArray();{/php}
	{notempty name="notice"}
		<div class="container">
			<section class="home-activities">
				<div data-sa-c="{ event: 'clickRecommend' }" class="home-activities__main">
					<div class="home-activities__main-list">
						{volist name="$notice" id="v"}
							<div class="home-activities__main-list-item">
								<a href="{:url('notice_detail',['id' => $v['id']])}" target="_blank" title="{$v.title}" class="ellipsis global-hover home-activities__main-list-item_title">{:dsubstr($v.title,46)}</a><span>{:time_format($v.create_time,'m-d')}</span>
							</div>
						{/volist}						
					</div>
				</div>
			</section>
		</div>
	{/notempty}

	<div class="container">
		<section class="editor-recommend">
			<section class="common-module">
				<div class="common-module__title"><span class="">主编力荐</span> </div>
				<div>
					<div class="editor-recommend__left">
						{php}$home_editor_main = isset($pageconf['home_editor_main']) ? model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_editor_main']])->order('level desc')->find() : '';{/php}
						{notempty name="home_editor_main"}
							{php}
								$book = model('book')->where(['id' => $home_editor_main['books']])->find();
								$link = $book ? url('book_detail', ['id' => $book['filename'] ? $book['filename'] : $book['id']]) : '';					
							{/php}
							{notempty name="book"}
								<div class="editor-recommend__left-coverImage global-book--shadow">
									<div class="editor-recommend__left-coverImage-cover global-book--frame">
										<a href="{$link}" target="_blank" title="{$home_editor_main.title}">
											<img src="{$home_editor_main.images}" alt="{$home_editor_main.title}" class="animation-img editor-recommend__left-coverImage-img">
										</a>
									</div>
									<div class="editor-recommend__left-coverImage-shadow global-radius"></div>
								</div>
								<div class="editor-recommend__left-currInfo">
									<a href="{$link}" target="_blank" title="{$home_editor_main.title}" class="currInfo-title global-hover ellipsis-two-lines">
										{$home_editor_main.title}
									</a>
									<a href="{$link}" target="_blank" title="{$home_editor_main.title}" class="currInfo-author ellipsis global-hover">
										{$book.author}
									</a>
									<a href="{$link}" target="_blank" title="{$home_editor_main.title}" class="currInfo-desc ellipsis-two-lines">
										{$home_editor_main.introduction}
									</a>
								</div>
							{/notempty}
						{/notempty}
					</div>
				</div>
			</section>
			<div class="editor-recommend__center">
				<div class="editor-recommend__center-recommend">
					{php}$home_editor_images = isset($pageconf['home_editor_images']) ? model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_editor_images']])->order('level desc')->limit(6)->select()->toArray() : '';{/php}
					{notempty name="home_editor_images"}					
					{volist name="$home_editor_images" id="v"}
						{php}
							$book = model('book')->where(['id' => $v['books']])->find();
							$link = $book ? url('book_detail', ['id' => $book['filename'] ? $book['filename'] : $book['id']]) : '';				
						{/php}
						{notempty name="book"}
							<div class="recommend-item">
								<div class="recommend-img global-book--shadow">
									<a href="{$link}" target="_blank" title="{$v.title}" class="recommend-img--cover global-radius global-book--frame">
										<img src="{$v.images}" alt="{$v.title}" class="animation-img">
									</a>
								</div>
								<div class="recommend-content">
									<div class="recommend-title ellipsis-two-lines global-hover">
										<a href="{$link}" target="_blank" title="{$v.title}" class="recommend-title ellipsis-two-lines global-hover">{$v.title}</a>
									</div>
									<div class="recommend-desc ellipsis-two-lines global-hover">
										<a href="{$link}" target="_blank" title="{$v.title}" class="recommend-desc ellipsis-two-lines global-hover">
											{$v.introduction}
										</a>
									</div>
									<div class="recommend-type ellipsis">
										<a href="{$link}" title="{$book.author}" target="_blank" class="global-hover">{$book.author}</a>
										<span>·</span>
										<a href="{$link}" title="{$v.title}" target="_blank" class="global-hover">{$book.isfinish == 2 ? '完结' : '连载'}</a>
									</div>
								</div>
							</div>
						{/notempty}
					{/volist}
					{/notempty}
				</div>
			</div>
			<section class="zh-modules-rank editor-recommend__rank">
				<div class="editor-recommend__rank-title"></div>
				<div class="zh-modules-rank-box">
					{php}$home_editor_top = isset($pageconf['home_editor_top']) ? model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_editor_top']])->order('level desc')->limit(10)->select()->toArray() : '';{/php}
					{notempty name="home_editor_top"}
						{volist name="$home_editor_top" id="v"}
							{php}$book = model('book')->where(['id' => $v['books']])->find();{/php}
							{notempty name="book"}
							<div class="zh-modules-rank-book">
								{eq name="$key" value="0"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/1940777.png" alt="{$v.title}"></div>{/eq}
								{eq name="$key" value="1"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/e452c9d.png" alt="{$v.title}"></div>{/eq}
								{eq name="$key" value="2"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/65b1446.png" alt="{$v.title}"></div>{/eq}
								{if condition="$key > 2 && $key < 9"}
									<div class="book-rank--num"><span>0{$key+1}</span></div>
								{/if}
								{eq name="$key" value="9"}<div class="book-rank--num"><span>10</span></div>{/eq}								
								<div class="book-rank--title">
									<p class="book-rank--title-text ellipsis"><a title="{$v.title}" target="_blank" href="{:url('book_detail', ['id' => $book['filename'] ? $book['filename'] : $book['id']])}" class="global-hover">{$v.title}</a></p>
									<div class="editor-recommend__rank-text">{$book.isfinish == 2 ? '完结' : '连载'}</div>
								</div>						
							</div>
							{/notempty}
						{/volist}
					{/notempty}
				</div>
			</section>
		</section>
	</div>
	{php}$home_banner_1 = isset($pageconf['home_banner_1']) ? model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_banner_1']])->order('level desc')->find() : '';{/php}
	{notempty name="home_banner_1"}
	<div class="container">
		{if $home_banner_1.type == 1}
			{php}
				$book = model('book')->where(['id'=> $home_banner_1['books'], 'status' => 1])->find();
				if($book) {
					$home_banner_1['link'] = url('book_detail', ['id' => $book['filename'] ? $book['filename'] : $book['id']]);
				}
			{/php}
			<a href="{$home_banner_1.link}" target="_blank" class="home-advertising">
				<img src="{$home_banner_1.images}">
			</a>
		{/if}
		{if $home_banner_1.type == 3}
			<a href="{$home_banner_1.link}" target="_blank" class="home-advertising">
				<img src="{$home_banner_1.images}">
			</a>
		{/if}
		{if $home_banner_1.type == 6}
			{php}
				$content = htmlspecialchars_decode($home_banner_1['advshtml']);
				$content = str_replace(['<br />', '&rdquo;', '&nbsp;'], ['', '"', ' '], $content);
				$home_banner_1['advshtml'] = preg_replace('/\s+/', ' ', $content);
			{/php}
			{$home_banner_1.advshtml|raw}
		{/if}		
	</div>
	{/notempty}

	<div class="container">
		<section class="website-rank">
			<div class="website-rank__main">
				<section class="zh-modules-rank website-rank__list" style="background-image:url('{__STATIC__}/home/image/8df48f1.png');">
					<div class="zh-modules-rank-box">
						{php}$chapter_top = model('book')->where(['status' => 1])->order('chapters desc')->limit(10)->select()->toArray();{/php}
						{notempty name="chapter_top"}
						{volist name="$chapter_top" id="vo"}
						{php}$link = url('book_detail', ['id' => $vo['filename'] ? $vo['filename'] : $vo['id']]);{/php}
						<div class="zh-modules-rank-book">
							{eq name="$key" value="0"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/1940777.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="1"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/e452c9d.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="2"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/65b1446.png" alt="{$vo.title}"></div>{/eq}
							{if condition="$key > 2 && $key < 9"}
								<div class="book-rank--num"><span>0{$key+1}</span></div>
							{/if}
							{eq name="$key" value="9"}<div class="book-rank--num"><span>10</span></div>{/eq}
							<div class="book-rank--title">
								<p class="book-rank--title-text ellipsis"><a title="{$vo['title']}" target="_blank" href="{$link}" class="global-hover">{$vo['title']}</a></p>
								<div class="website-rank__rank-text">{$vo.chapters}</div>
							</div>
						</div>
						{/volist}
						{/notempty}
					</div>
				</section>
				<section class="zh-modules-rank website-rank__list" style="background-image:url('{__STATIC__}/home/image/77e71dd.png');">
					<div class="zh-modules-rank-box">
						{php}$words_top = model('book')->where(['status' => 1])->order('words desc')->limit(10)->select()->toArray();{/php}
						{notempty name="words_top"}
						{volist name="$words_top" id="vo"}
						{php}$link = url('book_detail', ['id' => $vo['filename'] ? $vo['filename'] : $vo['id']]);{/php}
						<div class="zh-modules-rank-book">
							{eq name="$key" value="0"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/1940777.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="1"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/e452c9d.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="2"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/65b1446.png" alt="{$vo.title}"></div>{/eq}
							{if condition="$key > 2 && $key < 9"}
								<div class="book-rank--num"><span>0{$key+1}</span></div>
							{/if}
							{eq name="$key" value="9"}<div class="book-rank--num"><span>10</span></div>{/eq}
							<div class="book-rank--title">
								<p class="book-rank--title-text ellipsis"><a title="{$vo['title']}" target="_blank" href="{$link}" class="global-hover">{$vo['title']}</a></p>
								<div class="website-rank__rank-text">{:ceil($vo.words/10000)}万</div>
							</div>
						</div>
						{/volist}
						{/notempty}
					</div>
				</section>
				<section class="zh-modules-rank website-rank__list" style="background-image:url('{__STATIC__}/home/image/b51874d.png');">
					<div class="zh-modules-rank-box">
						{php}$hits_top = model('book')->where(['status' => 1])->order('hits desc')->limit(10)->select()->toArray();{/php}
						{notempty name="hits_top"}
						{volist name="$hits_top" id="vo"}
						{php}$link = url('book_detail', ['id' => $vo['filename'] ? $vo['filename'] : $vo['id']]);{/php}
						<div class="zh-modules-rank-book">
							{eq name="$key" value="0"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/1940777.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="1"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/e452c9d.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="2"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/65b1446.png" alt="{$vo.title}"></div>{/eq}
							{if condition="$key > 2 && $key < 9"}
								<div class="book-rank--num"><span>0{$key+1}</span></div>
							{/if}
							{eq name="$key" value="9"}<div class="book-rank--num"><span>10</span></div>{/eq}
							<div class="book-rank--title">
								<p class="book-rank--title-text ellipsis"><a title="{$vo['title']}" target="_blank" href="{$link}" class="global-hover">{$vo['title']}</a></p>
								<div class="website-rank__rank-text">{$vo.hits > 0 ? $vo.hits : '--' }</div>
							</div>
						</div>
						{/volist}
						{/notempty}
					</div>
				</section>
				<section class="zh-modules-rank website-rank__list" style="background-image:url('{__STATIC__}/home/image/9269490.png');">
					<div class="zh-modules-rank-box">
						{php}
						$book_count = model('book')->where(['status' => 1, ['chapters', '>', 0]])->count();
						if($book_count > 10) {
							$start = mt_rand(0, ($book_count - 10));
						} else {
							$start = 0;
						}
						$rand_top = model('book')->where(['status' => 1, ['chapters', '>', 0]])->order('chapters desc')->limit($start, 10)->select()->toArray();
						{/php}
						{notempty name="rand_top"}
						{volist name="$rand_top" id="vo"}
						{php}$link = url('book_detail', ['id' => $vo['filename'] ? $vo['filename'] : $vo['id']]);{/php}
						<div class="zh-modules-rank-book">
							{eq name="$key" value="0"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/1940777.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="1"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/e452c9d.png" alt="{$vo.title}"></div>{/eq}
							{eq name="$key" value="2"}<div class="book-rank--num"><img src="{__STATIC__}/home/image/65b1446.png" alt="{$vo.title}"></div>{/eq}
							{if condition="$key > 2 && $key < 9"}
								<div class="book-rank--num"><span>0{$key+1}</span></div>
							{/if}
							{eq name="$key" value="9"}<div class="book-rank--num"><span>10</span></div>{/eq}
							<div class="book-rank--title">
								<p class="book-rank--title-text ellipsis"><a title="{$vo['title']}" target="_blank" href="{$link}" class="global-hover">{$vo['title']}</a></p>
								<div class="website-rank__rank-text">{$vo.chapters}</div>
							</div>
						</div>
						{/volist}
						{/notempty}
					</div>
				</section>
			</div>
		</section>
	</div>

	{php}$home_banner_buttom = isset($pageconf['home_banner_buttom']) ? model('advsr')->where(['status' => 1, 'adver_id' => $pageconf['home_banner_buttom']])->order('level desc')->find() : '';{/php}
	{notempty name="home_banner_buttom"}
	<div class="container">
		{if $home_banner_buttom.type == 1}
			{php}
				$book = model('book')->where(['id'=> $home_banner_buttom['books'], 'status' => 1])->find();
				if($book) {
					$home_banner_buttom['link'] = url('book_detail', ['id' => $book['filename'] ? $book['filename'] : $book['id']]);
				}
			{/php}
			<a href="{$home_banner_buttom.link}" target="_blank" class="home-advertising">
				<img src="{$home_banner_buttom.images}">
			</a>
		{/if}
		{if $home_banner_buttom.type == 3}
			<a href="{$home_banner_buttom.link}" target="_blank" class="home-advertising">
				<img src="{$home_banner_buttom.images}">
			</a>
		{/if}
		{if $home_banner_buttom.type == 6}
			{php}
				$content = htmlspecialchars_decode($home_banner_buttom['advshtml']);
				$content = str_replace(['<br />', '&rdquo;', '&nbsp;'], ['', '"', ' '], $content);
				$home_banner_buttom['advshtml'] = preg_replace('/\s+/', ' ', $content);
			{/php}
			{$home_banner_buttom.advshtml|raw}
		{/if}
	</div>
	{/notempty}
	
	{php}
		$update_list = model('book')->field('id,genre,title as booktitle,filename,update_time,create_time,words,author')->where(['status' => 1])->orderRaw('CASE WHEN update_time > 0 THEN update_time ELSE create_time END DESC')->limit(20)->select()->toArray();
		if(!empty($update_list)) {
			foreach ($update_list as $k => $vo) {
				$update_list[$k]['link'] = (string) url('book_detail', ['id' => $vo['filename'] ? $vo['filename'] : $vo['id']]);
				if($vo['genre']) {
					$category = model('category')->where(['status' => 1, 'id' => $vo['genre']])->find();
					$update_list[$k]['genrelink'] = $category ? (string) url('book_cates', ['id' => $category['key'] ? $category['key'] : $category['id']]) : 'javascript:;';
					$update_list[$k]['genrename'] = $category ? $category['name'] : '--';
				} else {
					$update_list[$k]['genrename'] = '--';
					$update_list[$k]['genrelink'] = 'javascript:;';
				}
				$chapter = model('chapter')->field('id,bookid,title,chaps,create_time')->where(['bookid' => $vo['id'], 'status' => 1, ['verify', 'in', '0,1']])->order('create_time desc')->find();
				$update_list[$k]['chapterlink'] = $chapter ? (string) furl('chapter_detail', ['id' => $chapter['id'], 'bookid' => $vo['filename'] ? $vo['filename'] : $vo['id']]) : 'javascript:;';
				$update_list[$k]['title'] = $chapter ? $chapter['title'] : '--';
			}
		}
	{/php}
	{notempty name="update_list"}
		<div class="container">
			<section class="novel-update">
				<div class="zh-modules-nav">
					<div class="zh-modules-nav-cont">
						<div class="zh-modules-nav--item currTab"><span>最近更新</span></div>					
						<div class="el-tabs__active-bar"></div>
					</div>
				</div>
				<div class="novel-update_update-main">
					<ul class="update-menu">
						<li>类别</li>
						<li>书名</li>
						<li>章节名称</li>
						<li>字数</li>
						<li>作者</li>
						<li>更新时间</li>
					</ul>
					{volist name="$update_list" id="vo"}
					<ul>
						<li>
							<a title="{$vo['genrename']}" href="{$vo['genrelink']}" target="_blank">{$vo['genrename']}</a>
						</li>
						<li>
							<a title="{$vo['booktitle']}" href="{$vo['link']}" target="_blank" class="bookName global-hover update-bookName">{$vo['booktitle']}</a>
						</li>
						<li>
							<a href="{$vo['chapterlink']}" target="_blank" title="{$vo.title}" class="ellipsis chapter global-hover">{$vo.title}</a>
						</li>
						<li>{:wordCount($vo.words)}</li>
						<li>{$vo['author']}</li>
						<li>{:time_format(max($vo['create_time'], $vo['update_time']))}</li>
					</ul>
					{/volist}
				</div>
			</section>
		</div>
	{/notempty}
	{php}
	$links = [];
	if (get_addons_is_enable('sitegroup')) {
		$feiniaoLinks = hook('siteGroupLinksHook');
        if ($feiniaoLinks && isJson($feiniaoLinks)) {
            $links = json_decode($feiniaoLinks, true);
        }
    }
	if(empty($links)) {
		$links = model('links')->where(['status' => 1])->order('sort desc')->select()->toArray();
	}
	{/php}
	{notempty name="links"}
	<div class="container comm_friendLnk">
		<div class="comm_footer_partner">
			<div class="partner-title">合作伙伴</div>
			<div class="comm_footer_friendLnk">
				{volist name="$links" id="v"}
				<a href="{$v.src}"{eq name="$v.target" value="1"} target="_blank"{/eq}>{$v.name}</a>
				{/volist}
			</div>
		</div>
	</div>
	{/notempty}
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}	
    <script>
		$(document).ready(function() {
			$('.slider_list').owlCarousel({
				loop: true,
				autoplay: true,
				autoplayTimeout: 5000,
				dots: false,
				nav: false,
				navText: ["<i class='bi bi-arrow-left''></i>", "<i class='bi bi-arrow-right''></i>"],
				responsive: {
				0: {
					items: 1
				},
				768: {
					items: 1
				},
				992: {
					items: 1
				},
				1000: {
					items: 1
				},
				1920: {
					items: 1
				}
				}
			})
		});
    </script>
{/block}
<!-- /脚本 -->